<?php 
	Class activityreview extends CI_Controller{
		public function __construct(){
			parent::__construct();
			$this->load->model('model_activityreview');	
			$this->load->model('model_activity');
		}
		
		public function index(){
			$data["data"]=$this->model_activityreview->listall(20000,0);
			$data['activity']=$this->model_activity->getcolunm_allactivity('id, name');
			if(isset($_GET["id"])){
				$data["detail"]	= $this->model_activityreview->getdata(intval($_GET['id']));
			}else $data['detail']=NULL;
			$data["template"]="activity/activity_review";
			$this->load->view("layout",$data);
		}
		
		public function update(){
			if(isset($_GET["id"])){
				$data['name']=$_POST['name'];
				$data['title']=$_POST['title'];
				$data['contents']=$_POST['contents'];
				$data['createdate']=$_POST['createdate'];
				$data['mark']=$_POST['mark'];
				$data['activityid']=$_POST['activityid'];
				$this->model_activityreview->update($data,intval($_GET["id"]));				
				redirect('/admin/activityreview/index','refresh');
			}	
		}
		
		public function insert(){
			$data['name']=$_POST['name'];
				$data['title']=$_POST['title'];
				$data['contents']=$_POST['contents'];
				$data['createdate']=$_POST['createdate'];
				$data['mark']=$_POST['mark'];
				$data['activityid']=$_POST['activityid'];
				$this->model_activityreview->add($data);				
				redirect('/admin/activityreview/index','refresh');
		}
		
		public function delete(){
			if(isset($_GET["id"])){
				$this->model_activityreview->del(intval($_GET["id"]));	
				redirect('/admin/activityreview/index','refresh');				
			}	
		}
	}
?>